#ifndef __QUTILS_H__
#define __QUTILS_H__

#ifdef __cplusplus
extern "C"
{
#endif

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <math.h>

#define SIZEOFARRY(arry) (sizeof(arry) / sizeof(arry[0]))

uint16_t swap_uint16(uint16_t value);
int16_t swap_int16(int16_t value);
uint32_t swap_uint32(uint32_t value);
int32_t swap_int32(int32_t value);
uint64_t swap_uint64(uint64_t value);
int round_up(int val, int rnd);

void convert_hex_to_ascii_string(char *hex_data, char *ascii_string);
void dump_hex(char *head_text, unsigned char * data, uint32_t len);
uint8_t modbus_xor(unsigned char * data, uint16_t len);
uint8_t modbus_sum(unsigned char * data, uint16_t len);
uint16_t modbus_crc16(unsigned char * data, uint16_t len);
void tea_decrypt (uint32_t* v, uint32_t* key);
int32_t search_string_from_list(char *str, char** list, uint32_t arry_len);
void save_file(char *filename, void* data, uint32_t length);
int32_t create_path(char *path);
uint16_t argb8888_to_argb1555(uint32_t color);
uint32_t argb1555_to_argb8888(uint16_t color);
int32_t rgb888_to_argb1555(uint8_t *rgb, uint32_t size, uint16_t *argb1555);
int32_t argb1555_to_rgb888(uint16_t *argb1555, uint32_t size, uint8_t *rgb);
int32_t check_mount_device(const char *pdev);
int32_t binary_search_double(double *arr, int32_t low, int32_t high, double target);
void output_framrate(uint8_t *module, uint32_t interval, struct timeval *tm_start, uint32_t *fps_count);

#ifdef __cplusplus
};
#endif

#endif
